<tagLib name="html" />

<include file="Public:header" />

<div class="container" id="cpcontainer">

    <h3>{$Think.lang.theme.tpl_editor}</h3>
    <p class="tips">{$Think.lang.theme.tips}</p>

    <form name="cpform" method="post" action="__URL__/editTemplate">
    <input type="hidden" name="op" value="save" />
    <input type="hidden" name="file" value="{$tplFile}" id="file" />
    <table class="tb tb2">
        <tr class="nobg"><td colspan="2" class="td27"></td></tr>
        <tr>
            <td class="vtop rowform" colspan="2">
            {$Think.lang.theme.select_theme}:
            <html:select id="theme" name="theme" options="themeOptions" selected="themeSelected" onchange="changeTheme();" />
            {$Think.lang.theme.select_tpl_file}:
            <select id="tpl_file" name="tpl_file" onchange="changeTemplate();">
                <option value="">&gt;&gt;&nbsp;&nbsp;{$Think.lang.theme.select_tpl_file}</option>
                <volist name="templates" id="vo">
                    <optgroup label="{$key}">
                    <volist name="vo" id="sub">
                        <option value="{$sub.path|base64_encode}" <if condition="$tplFile eq $sub['path']">selected</if>>{$sub.name}</option>
                    </volist>
                    </optgroup>
                </volist>
            </select>
            </td>
        </tr>
        <notempty name="tplFile"><tr class="nobg"><th colspan="15" class="partition">{$Think.lang.theme.current_file} :: {$tplFile}</th></tr></notempty>
        <tr>
            <td class="vtop" colspan="2"><textarea id="tpl_content" name="tpl_content" style="width:100%;height:600px;">{$tplContent}</textarea></td>
        </tr>
        <tr class="nobg"><td colspan="15"><div class="fixsel"><input id="save" class="btn" type="submit" value="{$Think.lang.submit}" /></div></td></tr>
    </table>
    </form>
</div>

<script type="text/javascript">
$(function(){

});

function changeTheme(){
    var theme = $('#theme').val();
    var url = '__ACTION__/theme/'+theme;
    window.location.href = url;
}

function changeTemplate(){
    var theme = $('#theme').val();
    var tplFile = $('#tpl_file').val();
    if(tplFile == ''){
        return false;
    }
    var url = '__ACTION__/theme/'+theme+'/tpl_file/'+tplFile;
    window.location.href = url;
}
</script>

<include file="Public:footer" />